﻿<%@ Page MaintainScrollPositionOnPostback="true"  Title="Contracts" Theme="POSSystem" Language="C#" MasterPageFile="~/EditPages/Popup.Master" AutoEventWireup="true" CodeBehind="ViewContracts.aspx.cs" Inherits="WebUI.EditPages.ViewContracts" %>

<%@ Register Src="~/Controls/POSControls/ContractListCtrl.ascx" TagName="ContractList" TagPrefix="uc" %>

<asp:Content ID="Content1" ContentPlaceHolderID="PopupHeadHolder" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="PopupToolbarHolder" runat="server">

    <script type="text/javascript">
        
        
        function showUpdateMemo(btn) {
            var returnValue = window.showModalDialog('<%=GetUpdateMemoPageLink() %>' + '&mode=edit&id=' + btn.getAttribute("ItemID"), '', 'dialogWidth=600px;dialogHeight=300px;resizable=no;help=no;unadorned=yes;');
            
            if(returnValue > 0)
                var btnRefresh = document.getElementById("<%=btnRefresh.ClientID %>").click();
            return false;
        }

        function onEditContract() { 
            var id = getSelectedItemID<%=lstContract.ClientID %>();
            if(id == null){
                alert("No item was selected!");
                return false;
            }
            var returnValue = window.showModalDialog('<%=GetEditContractLink() %>' + '&mode=edit&id=' + id, '', 'dialogWidth=450px;dialogHeight=420px;resizable=no;help=no;unadorned=yes;');
            return returnValue > 0;
        }

        function onDeleteContract(){
            var id = getSelectedItemID<%=lstContract.ClientID %>();
            if(id == null){
                alert("No item was selected!");
                return false;
            }

            return confirm("This action will delete the selected contract and its related invoice. Do you want to continue?");
        }

        function selectNewContract(){
            var btnNew = document.getElementById("<%= btnNew.ClientID %>");
            var btnPaid = document.getElementById("<%= btnPaid.ClientID %>");
            if(btnNew.className){
                btnNew.className = "selectedbutton";
                btnPaid.className = "tbbutton";
            }
            else{
                btnNew.setAttribute("class", "selectedbutton");
                btnNew.setAttribute("class", "tbbutton");
            }
        }

        function selectPaidContract(){
            var btnNew = document.getElementById("<%= btnNew.ClientID %>");
            var btnPaid = document.getElementById("<%= btnPaid.ClientID %>");
            if(btnNew.className){
                btnNew.className = "tbbutton";
                btnPaid.className = "selectedbutton";
            }
            else{
                btnNew.setAttribute("class", "tbbutton");
                btnNew.setAttribute("class", "selectedbutton");
            }
        }
    </script>
    
    <asp:Button ID="btnRefresh" runat="server" OnClick="btnRefresh_OnClick" style="display:none" />
    
    <table class="popuptoolbar" width="100%">
        <tr>
            <td style="vertical-align:middle; text-align:left">
                <asp:LinkButton class="selectedbutton" ID="btnNew" runat="server" OnClick="btnNewContract_OnClick">
                    <img src="Images/unchecked.png" /><asp:Label ID="label1" runat="server" Text="New Contract"></asp:Label>
                </asp:LinkButton>
                <asp:LinkButton class="tbbutton" ID="btnPaid" runat="server" OnClientClick="selectPaidContract();" OnClick="btnPaidContract_OnClick">
                    <img src="Images/checked.png" /><asp:Label ID="label2" runat="server" Text="Paid Contract"></asp:Label>
                </asp:LinkButton>
                <img src="../Images/tbSep.png" />
                
                <asp:LinkButton class="tbbutton" ID="lnkEditContract" runat="server" OnClientClick="return onEditContract();" OnClick="btnEditContract_OnClick">
                    <img src="~/Images/Edit.gif" runat="server" /><asp:Label ID="label4" runat="server" Text="Edit Contract Info"></asp:Label>
                </asp:LinkButton>
                <asp:LinkButton class="tbbutton" ID="lnkDeleteContract" runat="server" OnClientClick="return onDeleteContract();" OnClick="btnDeleteContract_OnClick">
                    <img id="Img1" src="~/Images/Delete.gif" runat="server" /><asp:Label ID="label3" runat="server" Text="Delete Contract"></asp:Label>
                </asp:LinkButton>
            </td>
        </tr>
    </table>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="PopupContentHolder" runat="server">
    <div style="height:560px; overflow:scroll">
        <uc:ContractList ID="lstContract" runat="server" AllowPaging="true" AllowSelecting="true" AllowSorting="true" 
            SaveOnCommit="false" PageSize="10" Width="100%"></uc:ContractList>

    </div>
</asp:Content>
